<template>
  <div>
    学生个人信息查询
    <el-row>
      <el-col :span="6" :offset="8">
        <el-input v-model="stu_id"></el-input>
      </el-col>
      <el-col :span="4" :offset="1">
        <el-button @click="search">搜索</el-button>
      </el-col>
    </el-row>
    <div class="table_box" v-if="show">
      <div class="stu_img">
        <img
          :src="result[0].stu_head_img"
          alt=""
          width="160px"
          height="160px"
        />
      </div>
      <div class="table_wrap">
        <el-table :data="result" style="width: 100%">
          <el-table-column prop="stu_id" label="学号" width="180">
          </el-table-column>
          <el-table-column prop="stu_name" label="姓名" width="180">
          </el-table-column>
          <el-table-column prop="stu_jg" label="籍贯"> </el-table-column>
          <el-table-column prop="stu_sex" label="性别" width="180">
          </el-table-column>
          <el-table-column prop="stu_hobby" label="爱好" width="180">
          </el-table-column>
          <el-table-column prop="stu_date" label="出生日期" width="180">
          </el-table-column>
          <el-table-column prop="stu_gbf" label="男或女朋友" width="180">
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import { req_stu_info_personal } from "@/api/stuInfo.js";
export default {
  data() {
    return {
      stu_id: "",
      stu_name: "",
      stu_jg: "",
      stu_sex: "",
      stu_hobby: "",
      stu_date: "",
      stu_gbf: "",
      stu_head_img: "",
      result: [],
      show: false,
    };
  },
  methods: {
    async search() {
      console.log(this.stu_id);
      let result = await req_stu_info_personal(this.stu_id);
      console.log(result);
      this.result = result.data;
      this.show = true;
      console.log(this.result);
    },
  },
};
</script>

<style lang="scss" scoped>
.stu_img{
  display: flex;
  justify-content: center;
}
</style>